


"""simple docstring"""







import numpy as np
from scipy.spatial.distance import cdist
from sklearn.metrics import fa_score

import datasets


__lowercase    =				"""\
    @inproceedings{kakwani2020indicnlpsuite,
    title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models for Indian Languages}},
    author={Divyanshu Kakwani and Anoop Kunchukuttan and Satish Golla and Gokul N.C. and Avik Bhattacharyya and Mitesh M. Khapra and Pratyush Kumar},
    year={2020},
    booktitle={Findings of EMNLP},
}
"""

__lowercase    =				"""\
    IndicGLUE is a natural language understanding benchmark for Indian languages. It contains a wide
    variety of tasks and covers 11 major Indian languages - as, bn, gu, hi, kn, ml, mr, or, pa, ta, te.
"""

__lowercase    =				"""
Compute IndicGLUE evaluation metric associated to each IndicGLUE dataset.
Args:
    predictions: list of predictions to score (as int64),
        except for 'cvit-mkb-clsr' where each prediction is a vector (of float32).
    references: list of ground truth labels corresponding to the predictions (as int64),
        except for 'cvit-mkb-clsr' where each reference is a vector (of float32).
Returns: depending on the IndicGLUE subset, one or several of:
    \"accuracy\": Accuracy
    \"f1\": F1 score
    \"precision\": Precision@10
Examples:

    >>> indic_glue_metric = datasets.load_metric('indic_glue', 'wnli')  # 'wnli' or any of [\"copa\", \"sna\", \"csqa\", \"wstp\", \"inltkh\", \"bbca\", \"iitp-mr\", \"iitp-pr\", \"actsa-sc\", \"md\"]
    >>> references = [0, 1]
    >>> predictions = [0, 1]
    >>> results = indic_glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0}

    >>> indic_glue_metric = datasets.load_metric('indic_glue', 'wiki-ner')
    >>> references = [0, 1]
    >>> predictions = [0, 1]
    >>> results = indic_glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0, 'f1': 1.0}

    >>> indic_glue_metric = datasets.load_metric('indic_glue', 'cvit-mkb-clsr')
    >>> references = [[0.5, 0.5, 0.5], [0.1, 0.2, 0.3]]
    >>> predictions = [[0.5, 0.5, 0.5], [0.1, 0.2, 0.3]]
    >>> results = indic_glue_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'precision@10': 1.0}

"""


def 					lowercase      (    A_  ,       A_	)->				Union[str, Any]:
  '''simple docstring'''







  return float((preds == labels).mean()	)


def 					lowercase      (    A_  ,       A_	)->				str:
  '''simple docstring'''







  a						:		int											=      simple_accuracy(A_  ,       A_	)
  a						:		Optional[int]											=      float(fa_score(y_true=A_  ,       y_pred=A_	)	)
  return {
      "accuracy": acc,
      "f1": fa,
  }


def 					lowercase      (    A_  ,       A_	)->				int:
  '''simple docstring'''







  a						:		Union[str, Any]											=      np.array(A_	)
  a						:		List[str]											=      np.array(A_	)
  a						:		Tuple											=      en_sentvecs.shape[0]

  # mean centering
  a						:		Tuple											=      en_sentvecs - np.mean(A_  ,       axis=0	)
  a						:		Dict											=      in_sentvecs - np.mean(A_  ,       axis=0	)

  a						:		Optional[Any]											=      cdist(A_  ,       A_  ,       "cosine"	)
  a						:		Optional[Any]											=      np.array(range(A_	)	)
  a						:		Optional[Any]											=      sim.argsort(axis=1	)[:, :10]
  a						:		Any											=      np.any(preds == actual[:, None]  ,       axis=1	)
  return float(matches.mean()	)







@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION   ,_KWARGS_DESCRIPTION  )
class 						_A  (  datasets.Metric  ):







    """simple docstring"""




    def      __snake_case							( self    :   Union[str, Any]):
      if self.config_name not in [
          "wnli",
          "copa",
          "sna",
          "csqa",
          "wstp",
          "inltkh",
          "bbca",
          "cvit-mkb-clsr",
          "iitp-mr",
          "iitp-pr",
          "actsa-sc",
          "md",
          "wiki-ner",
      ]:
        raise KeyError(
            "You should supply a configuration name selected in "
            "[\"wnli\", \"copa\", \"sna\", \"csqa\", \"wstp\", \"inltkh\", \"bbca\", "
            "\"cvit-mkb-clsr\", \"iitp-mr\", \"iitp-pr\", \"actsa-sc\", \"md\", "
            "\"wiki-ner\"]")
      return datasets.MetricInfo(
          description=_DESCRIPTION    ,			citation=_CITATION    ,			inputs_description=_KWARGS_DESCRIPTION    ,			features=datasets.Features(
              {
                  "predictions": datasets.Value("int64")
                  if self.config_name != "cvit-mkb-clsr"
                  else datasets.Sequence(datasets.Value("float32")),
                  "references": datasets.Value("int64")
                  if self.config_name != "cvit-mkb-clsr"
                  else datasets.Sequence(datasets.Value("float32")),
              })    ,			codebase_urls=[]    ,			reference_urls=[]    ,			format="numpy" if self.config_name != "cvit-mkb-clsr" else None    ,			)






    def      __snake_case							( self    :   Any    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Dict):
      if self.config_name == "cvit-mkb-clsr":
        return {"precision@10": precision_at_aa(__UpperCAmelCase    ,			__UpperCAmelCase)}
      elif self.config_name in ["wiki-ner"]:
        return acc_and_fa(__UpperCAmelCase    ,			__UpperCAmelCase)
      elif self.config_name in [
          "wnli",
          "copa",
          "sna",
          "csqa",
          "wstp",
          "inltkh",
          "bbca",
          "iitp-mr",
          "iitp-pr",
          "actsa-sc",
          "md",
      ]:
        return {"accuracy": simple_accuracy(__UpperCAmelCase    ,			__UpperCAmelCase)}
      else:
        raise KeyError(
            "You should supply a configuration name selected in "
            "[\"wnli\", \"copa\", \"sna\", \"csqa\", \"wstp\", \"inltkh\", \"bbca\", "
            "\"cvit-mkb-clsr\", \"iitp-mr\", \"iitp-pr\", \"actsa-sc\", \"md\", "
            "\"wiki-ner\"]")










"""simple docstring"""







from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


__lowercase    =				logging.get_logger(__name__)


# General docstring
__lowercase    =				"""MobileNetV1Config"""

# Base docstring
__lowercase    =				"""google/mobilenet_v1_1.0_224"""
__lowercase    =				[1, 1024, 7, 7]

# Image classification docstring
__lowercase    =				"""google/mobilenet_v1_1.0_224"""
__lowercase    =				"""tabby, tabby cat"""


__lowercase    =				[
    """google/mobilenet_v1_1.0_224""",
    """google/mobilenet_v1_0.75_192""",
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]


def 					lowercase      (    A_  ,       A_  ,       A_=None	)->				int:
  '''simple docstring'''







  a						:		Union[str, Any]											=      {}

  if isinstance(A_  ,       A_	):
    a						:		Tuple											=      model.mobilenet_va
  else:
    a						:		Optional[int]											=      model

  a						:		Any											=      "MobilenetV1/Conv2d_0/"
  a						:		List[Any]											=      backbone.conv_stem.convolution.weight
  a						:		Tuple											=      backbone.conv_stem.normalization.bias
  a						:		int											=      backbone.conv_stem.normalization.weight
  a						:		Optional[int]											=      backbone.conv_stem.normalization.running_mean
  a						:		Dict											=      backbone.conv_stem.normalization.running_var

  for i in range(13	):
    a						:		Dict											=      i + 1
    a						:		str											=      i * 2

    a						:		str											=      backbone.layer[pt_index]
    a						:		Tuple											=      F'''MobilenetV1/Conv2d_{tf_index}_depthwise/'''
    a						:		Union[str, Any]											=      pointer.convolution.weight
    a						:		Optional[int]											=      pointer.normalization.bias
    a						:		Any											=      pointer.normalization.weight
    a						:		Optional[int]											=      pointer.normalization.running_mean
    a						:		Dict											=      pointer.normalization.running_var

    a						:		Dict											=      backbone.layer[pt_index + 1]
    a						:		List[str]											=      F'''MobilenetV1/Conv2d_{tf_index}_pointwise/'''
    a						:		Dict											=      pointer.convolution.weight
    a						:		Any											=      pointer.normalization.bias
    a						:		List[Any]											=      pointer.normalization.weight
    a						:		Tuple											=      pointer.normalization.running_mean
    a						:		List[str]											=      pointer.normalization.running_var

  if isinstance(A_  ,       A_	):
    a						:		Dict											=      "MobilenetV1/Logits/Conv2d_1c_1x1/"
    a						:		List[Any]											=      model.classifier.weight
    a						:		Optional[int]											=      model.classifier.bias

  return tf_to_pt_map


def 					lowercase      (    A_  ,       A_  ,       A_	)->				Optional[int]:
  '''simple docstring'''







  try:
    import numpy as np
    import tensorflow as tf
  except ImportError:
    logger.error(
        "Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see "
        "https://www.tensorflow.org/install/ for installation instructions."	)
    raise

  # Load weights from TF model
  a						:		List[str]											=      tf.train.list_variables(A_	)
  a						:		Dict											=      {}
  for name, shape in init_vars:
    logger.info(F'''Loading TF weight {name} with shape {shape}'''	)
    a						:		List[str]											=      tf.train.load_variable(A_  ,       A_	)
    a						:		int											=      array

  # Build TF to PyTorch weights loading map
  a						:		int											=      _build_tf_to_pytorch_map(A_  ,       A_  ,       A_	)

  for name, pointer in tf_to_pt_map.items():
    logger.info(F'''Importing {name}'''	)
    if name not in tf_weights:
      logger.info(F'''{name} not in tf pre-trained weights, skipping'''	)
      continue

    a						:		Tuple											=      tf_weights[name]

    if "depthwise_weights" in name:
      logger.info("Transposing depthwise"	)
      a						:		Optional[Any]											=      np.transpose(A_  ,       (2, 3, 0, 1)	)
    elif "weights" in name:
      logger.info("Transposing"	)
      if len(pointer.shape	) == 2:  # copying into linear layer
        a						:		List[str]											=      array.squeeze().transpose()
      else:
        a						:		List[str]											=      np.transpose(A_  ,       (3, 2, 0, 1)	)

    if pointer.shape != array.shape:
      raise ValueError(F'''Pointer shape {pointer.shape} and array shape {array.shape} mismatched'''	)

    logger.info(F'''Initialize PyTorch weight {name} {array.shape}'''	)
    a						:		Any											=      torch.from_numpy(A_	)

    tf_weights.pop(A_  ,       A_	)
    tf_weights.pop(name + "/RMSProp"  ,       A_	)
    tf_weights.pop(name + "/RMSProp_1"  ,       A_	)
    tf_weights.pop(name + "/ExponentialMovingAverage"  ,       A_	)

  logger.info(F'''Weights not copied to PyTorch model: {", ".join(tf_weights.keys()	)}'''	)
  return model


def 					lowercase      (    A_  ,       A_	)->				torch.Tensor:
  '''simple docstring'''







  a							,		a						:		str											=      features.shape[-2:]
  a							,		a						:		Tuple											=      conv_layer.stride
  a							,		a						:		Union[str, Any]											=      conv_layer.kernel_size

  if in_height % stride_height == 0:
    a						:		Union[str, Any]											=      max(kernel_height - stride_height  ,       0	)
  else:
    a						:		Tuple											=      max(kernel_height - (in_height % stride_height)  ,       0	)

  if in_width % stride_width == 0:
    a						:		Optional[int]											=      max(kernel_width - stride_width  ,       0	)
  else:
    a						:		int											=      max(kernel_width - (in_width % stride_width)  ,       0	)

  a						:		List[Any]											=      pad_along_width // 2
  a						:		List[str]											=      pad_along_width - pad_left
  a						:		str											=      pad_along_height // 2
  a						:		Any											=      pad_along_height - pad_top

  a						:		Tuple											=      (pad_left, pad_right, pad_top, pad_bottom)
  return nn.functional.pad(A_  ,       A_  ,       "constant"  ,       0.0	)






class 						_A  (  nn.Module  ):







    """simple docstring"""




    def __init__( self    :   Dict    ,			__UpperCAmelCase    :   MobileNetVaConfig    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Optional[int] = 1    ,			__UpperCAmelCase    :   Optional[int] = 1    ,			__UpperCAmelCase    :   bool = False    ,			__UpperCAmelCase    :   Optional[bool] = True    ,			__UpperCAmelCase    :   Optional[bool or str] = True    ,			):
      super().__init__()
      a						:		Optional[Any]											=      config

      if in_channels % groups != 0:
        raise ValueError(f'''Input channels ({in_channels}) are not divisible by {groups} groups.''')
      if out_channels % groups != 0:
        raise ValueError(f'''Output channels ({out_channels}) are not divisible by {groups} groups.''')

      a						:		Dict											=      0 if config.tf_padding else int((kernel_size - 1) / 2)

      a						:		List[str]											=      nn.Convad(
          in_channels=__UpperCAmelCase    ,			out_channels=__UpperCAmelCase    ,			kernel_size=__UpperCAmelCase    ,			stride=__UpperCAmelCase    ,			padding=__UpperCAmelCase    ,			groups=__UpperCAmelCase    ,			bias=__UpperCAmelCase    ,			padding_mode="zeros"    ,			)

      if use_normalization:
        a						:		str											=      nn.BatchNormad(
            num_features=__UpperCAmelCase    ,			eps=config.layer_norm_eps    ,			momentum=0.9_997    ,			affine=__UpperCAmelCase    ,			track_running_stats=__UpperCAmelCase    ,			)
      else:
        a						:		List[str]											=      None

      if use_activation:
        if isinstance(__UpperCAmelCase    ,			__UpperCAmelCase):
          a						:		Optional[int]											=      ACTaFN[use_activation]
        elif isinstance(config.hidden_act    ,			__UpperCAmelCase):
          a						:		Optional[Any]											=      ACTaFN[config.hidden_act]
        else:
          a						:		str											=      config.hidden_act
      else:
        a						:		Dict											=      None






    def      __snake_case							( self    :   Tuple    ,			__UpperCAmelCase    :   torch.Tensor):
      if self.config.tf_padding:
        a						:		Tuple											=      apply_tf_padding(__UpperCAmelCase    ,			self.convolution)
      a						:		Dict											=      self.convolution(__UpperCAmelCase)
      if self.normalization is not None:
        a						:		List[str]											=      self.normalization(__UpperCAmelCase)
      if self.activation is not None:
        a						:		Optional[Any]											=      self.activation(__UpperCAmelCase)
      return features






class 						_A  (  _a  ):







    """simple docstring"""




    UpperCAmelCase	:							Union[str, Any]     =	MobileNetVaConfig
    UpperCAmelCase	:							str     =	load_tf_weights_in_mobilenet_va
    UpperCAmelCase	:							List[str]     =	"""mobilenet_v1"""
    UpperCAmelCase	:							Dict     =	"""pixel_values"""
    UpperCAmelCase	:							str     =	False






    def      __snake_case							( self    :   str    ,			__UpperCAmelCase    :   Union[nn.Linear, nn.Convad]):
      if isinstance(__UpperCAmelCase    ,			(nn.Linear, nn.Convad)):
        module.weight.data.normal_(mean=0.0    ,			std=self.config.initializer_range)
        if module.bias is not None:
          module.bias.data.zero_()
      elif isinstance(__UpperCAmelCase    ,			nn.BatchNormad):
        module.bias.data.zero_()
        module.weight.data.fill_(1.0)






__lowercase    =				R"""
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`MobileNetV1Config`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""

__lowercase    =				R"""
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`MobileNetV1ImageProcessor.__call__`] for details.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""






@add_start_docstrings(
    """The bare MobileNetV1 model outputting raw hidden-states without any specific head on top."""   ,_a   ,)
class 						_A  (  _a  ):







    """simple docstring"""




    def __init__( self    :   Optional[int]    ,			__UpperCAmelCase    :   MobileNetVaConfig    ,			__UpperCAmelCase    :   bool = True):
      super().__init__(__UpperCAmelCase)
      a						:		List[str]											=      config

      a						:		List[Any]											=      32
      a						:		Union[str, Any]											=      max(int(depth * config.depth_multiplier)    ,			config.min_depth)

      a						:		List[str]											=      MobileNetVaConvLayer(
          __UpperCAmelCase    ,			in_channels=config.num_channels    ,			out_channels=__UpperCAmelCase    ,			kernel_size=3    ,			stride=2    ,			)

      a						:		int											=      [1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

      a						:		List[Any]											=      nn.ModuleList()
      for i in range(13):
        a						:		Optional[Any]											=      out_channels

        if strides[i] == 2 or i == 0:
          depth *= 2
          a						:		List[str]											=      max(int(depth * config.depth_multiplier)    ,			config.min_depth)

        self.layer.append(
            MobileNetVaConvLayer(
                __UpperCAmelCase    ,			in_channels=__UpperCAmelCase    ,			out_channels=__UpperCAmelCase    ,			kernel_size=3    ,			stride=strides[i]    ,			groups=__UpperCAmelCase    ,			))

        self.layer.append(
            MobileNetVaConvLayer(
                __UpperCAmelCase    ,			in_channels=__UpperCAmelCase    ,			out_channels=__UpperCAmelCase    ,			kernel_size=1    ,			))

      a						:		Optional[Any]											=      nn.AdaptiveAvgPoolad((1, 1)) if add_pooling_layer else None

      # Initialize weights and apply final processing
      self.post_init()






    def      __snake_case							( self    :   Optional[Any]    ,			__UpperCAmelCase    :   Any):
      raise NotImplementedError






    @add_start_docstrings_to_model_forward(__UpperCAmelCase)
    @add_code_sample_docstrings(
        checkpoint=_CHECKPOINT_FOR_DOC    ,			output_type=__UpperCAmelCase    ,			config_class=_CONFIG_FOR_DOC    ,			modality="vision"    ,			expected_output=_EXPECTED_OUTPUT_SHAPE    ,			)
    def      __snake_case							( self    :   List[Any]    ,			__UpperCAmelCase    :   Optional[torch.Tensor] = None    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			):
      a						:		str											=      (
          output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
      )
      a						:		Optional[Any]											=      return_dict if return_dict is not None else self.config.use_return_dict

      if pixel_values is None:
        raise ValueError("You have to specify pixel_values")

      a						:		Optional[int]											=      self.conv_stem(__UpperCAmelCase)

      a						:		Tuple											=      () if output_hidden_states else None

      for i, layer_module in enumerate(self.layer):
        a						:		Union[str, Any]											=      layer_module(__UpperCAmelCase)

        if output_hidden_states:
          a						:		str											=      all_hidden_states + (hidden_states,)

      a						:		Dict											=      hidden_states

      if self.pooler is not None:
        a						:		Optional[int]											=      torch.flatten(self.pooler(__UpperCAmelCase)    ,			start_dim=1)
      else:
        a						:		List[str]											=      None

      if not return_dict:
        return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None)

      return BaseModelOutputWithPoolingAndNoAttention(
          last_hidden_state=__UpperCAmelCase    ,			pooler_output=__UpperCAmelCase    ,			hidden_states=__UpperCAmelCase    ,			)






@add_start_docstrings(
    """
    MobileNetV1 model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    """   ,_a   ,)
class 						_A  (  _a  ):







    """simple docstring"""




    def __init__( self    :   int    ,			__UpperCAmelCase    :   MobileNetVaConfig):
      super().__init__(__UpperCAmelCase)

      a						:		Dict											=      config.num_labels
      a						:		Union[str, Any]											=      MobileNetVaModel(__UpperCAmelCase)

      a						:		List[Any]											=      self.mobilenet_va.layer[-1].convolution.out_channels

      # Classifier head
      a						:		Union[str, Any]											=      nn.Dropout(config.classifier_dropout_prob    ,			inplace=__UpperCAmelCase)
      a						:		Optional[int]											=      nn.Linear(__UpperCAmelCase    ,			config.num_labels) if config.num_labels > 0 else nn.Identity()

      # Initialize weights and apply final processing
      self.post_init()






    @add_start_docstrings_to_model_forward(__UpperCAmelCase)
    @add_code_sample_docstrings(
        checkpoint=_IMAGE_CLASS_CHECKPOINT    ,			output_type=__UpperCAmelCase    ,			config_class=_CONFIG_FOR_DOC    ,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT    ,			)
    def      __snake_case							( self    :   Dict    ,			__UpperCAmelCase    :   Optional[torch.Tensor] = None    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			__UpperCAmelCase    :   Optional[torch.Tensor] = None    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			):
      a						:		Union[str, Any]											=      return_dict if return_dict is not None else self.config.use_return_dict

      a						:		Dict											=      self.mobilenet_va(__UpperCAmelCase    ,			output_hidden_states=__UpperCAmelCase    ,			return_dict=__UpperCAmelCase)

      a						:		List[Any]											=      outputs.pooler_output if return_dict else outputs[1]

      a						:		List[Any]											=      self.classifier(self.dropout(__UpperCAmelCase))

      a						:		Any											=      None
      if labels is not None:
        if self.config.problem_type is None:
          if self.num_labels == 1:
            a						:		List[str]											=      "regression"
          elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
            a						:		Any											=      "single_label_classification"
          else:
            a						:		Optional[Any]											=      "multi_label_classification"

        if self.config.problem_type == "regression":
          a						:		Union[str, Any]											=      MSELoss()
          if self.num_labels == 1:
            a						:		Tuple											=      loss_fct(logits.squeeze()    ,			labels.squeeze())
          else:
            a						:		Dict											=      loss_fct(__UpperCAmelCase    ,			__UpperCAmelCase)
        elif self.config.problem_type == "single_label_classification":
          a						:		Optional[Any]											=      CrossEntropyLoss()
          a						:		Tuple											=      loss_fct(logits.view(-1    ,			self.num_labels)    ,			labels.view(-1))
        elif self.config.problem_type == "multi_label_classification":
          a						:		Dict											=      BCEWithLogitsLoss()
          a						:		List[Any]											=      loss_fct(__UpperCAmelCase    ,			__UpperCAmelCase)

      if not return_dict:
        a						:		int											=      (logits,) + outputs[2:]
        return ((loss,) + output) if loss is not None else output

      return ImageClassifierOutputWithNoAttention(
          loss=__UpperCAmelCase    ,			logits=__UpperCAmelCase    ,			hidden_states=outputs.hidden_states    ,			)






