Revert "add a cast function that suppresses -Wcast-function-type-strict (#100170)"

This reverts commit 642f4ed606b3d66bab21d44019ae5762637eeca9.

Reverted https://github.com/pytorch/pytorch/pull/100170 on behalf of https://github.com/atalman due to breaking internal builds ([comment](https://github.com/pytorch/pytorch/pull/100170#issuecomment-1540140636))
diff --git a/torch/csrc/Layout.cpp b/torch/csrc/Layout.cpp
index 3d32d55..4b56805 100644
--- a/torch/csrc/Layout.cpp
+++ b/torch/csrc/Layout.cpp
@@ -3,7 +3,6 @@
 #include <torch/csrc/Exceptions.h>
 #include <torch/csrc/utils/object_ptr.h>
 #include <torch/csrc/utils/python_strings.h>
-#include <torch/csrc/utils/unsafe_cast_function.h>
 
 #include <ATen/Layout.h>
 
@@ -36,7 +35,7 @@
     nullptr, /* tp_getattr */
     nullptr, /* tp_setattr */
     nullptr, /* tp_reserved */
-    torch::unsafe_cast_function<reprfunc>(THPLayout_repr), /* tp_repr */
+    (reprfunc)THPLayout_repr, /* tp_repr */
     nullptr, /* tp_as_number */
     nullptr, /* tp_as_sequence */
     nullptr, /* tp_as_mapping */
diff --git a/torch/csrc/utils/pycfunction_helpers.h b/torch/csrc/utils/pycfunction_helpers.h
index 77629f3..745e184 100644
--- a/torch/csrc/utils/pycfunction_helpers.h
+++ b/torch/csrc/utils/pycfunction_helpers.h
@@ -1,9 +1,13 @@
 #pragma once
 
-#include <torch/csrc/utils/unsafe_cast_function.h>
+#include <c10/macros/Macros.h>
 
 #include <Python.h>
 
 inline PyCFunction castPyCFunctionWithKeywords(PyCFunctionWithKeywords func) {
-  return torch::unsafe_cast_function<PyCFunction>(func);
+  C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type")
+  C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type-strict")
+  return reinterpret_cast<PyCFunction>(func);
+  C10_DIAGNOSTIC_POP()
+  C10_DIAGNOSTIC_POP()
 }
diff --git a/torch/csrc/utils/unsafe_cast_function.h b/torch/csrc/utils/unsafe_cast_function.h
deleted file mode 100644
index 660376c..0000000
--- a/torch/csrc/utils/unsafe_cast_function.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-
-#include <type_traits>
-
-#include <c10/macros/Macros.h>
-
-namespace torch {
-
-template <typename To, typename From>
-To unsafe_cast_function(From func) {
-  static_assert(std::is_pointer_v<To>);
-  static_assert(std::is_function_v<std::remove_pointer_t<To>>);
-  static_assert(std::is_pointer_v<From>);
-  static_assert(std::is_function_v<std::remove_pointer_t<From>>);
-
-  C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type")
-  C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type-strict")
-  return reinterpret_cast<To>(func);
-  C10_DIAGNOSTIC_POP()
-  C10_DIAGNOSTIC_POP()
-}
-
-} // namespace torch